package com.njit.mailm.core.bean;

import com.njit.mailm.commmon.constant.MailConstant;
import com.sun.mail.imap.protocol.Item;

/**
 * Created by Administrator on 2016/4/7.
 */
public class Page {
    private int page;
    private int pageitems = MailConstant.PAGEITEMS;
    private int startitem;
    private int nextPage;
    private int prevPage;
    private int totalPage;
    private int totalItems;

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageitems() {
        return pageitems;
    }

    public void setPageitems(int pageitems) {
        this.pageitems = pageitems;
    }

    public int getStartitem() {
        return (page - 1)* pageitems;
    }

    public int getNextPage() {
        if(page == getTotalPage()){
            return page;
        }
        return page+1;
    }

    public int getPrevPage() {
        if(page == 1){
            return 1;
        }
        return page -1;
    }

    public int getTotalPage() {
        if(totalItems%pageitems == 0){
            return totalItems/pageitems;
        }
        return totalItems/pageitems + 1;
    }

    public int getTotalItems() {
        return totalItems;
    }

    public void setTotalItems(int totalItems) {
        this.totalItems = totalItems;
    }
}
